home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Belgian Amiga Club - ADF Collection
/
BS1 part 19.zip
/
BS1 part 19
/
how to learn assembler.adf
/
CH4
/
4_3_3Bhex-conv.asm
< prev
next >
Wrap
Assembly Source File
|
1988-02-25
|
928b
|
32 lines
;(4.3.3B) hex convert
hexin: ; Converting a hex number
clr.l d1 ; First erase D1
move.l #string,a0 ; Address of the string in A0
hexinloop:
tst.b (a0) ; Test digit
beq hexinok ; If zero, then done
bsr nibblein ; Convert digit
lsl.l #4,d1 ; Shift result
or.b d0,d1 ; Insert nibble
bra hexinloop ; And continue
hexinok:
rts
nibblein: ; Convert the nibble from (A0)
clr.l d0 ; Erase D0
move.b (a0)+,d0 ; Get digit, increment A0
sub #'A',d0 ; Subtract $41
bcc ischar ; No problem, in the range A-F
add #7,d0 ; Else correct value
ischar:
add #10,d0 ; Correct value
rts
string: DC.B '56789ABC',00 ; 8 Digit string ending with a null byte
; that we want to convert
end